//
// Mirror.glsl
// Mirror
//
// Copyright (C) 2009
// Julius Parishy
//

uniform sampler2D webcam_texture;

uniform float delta_time;
uniform float elapsed_time;
uniform int mirror_direction;
uniform int someIntVar;

void main()
{
	vec2 coord = gl_TexCoord[0].st;

	if(mirror_direction == 0)
	{
		if(coord.s > 0.5)
		{
			float s = coord.s;
			coord.s = s - ((s - 0.5) * 2.0);
		}
	}
	else if(mirror_direction == 1)
	{
		if(coord.t > 0.5)
		{
			float t = coord.t;
			coord.t = t - ((t - 0.5) * 2.0);
		}
	}

	//coord.s = coord.s * cos(elapsed_time) * 5.0;
	//coord.t = coord.t * sin(elapsed_time) * 5.0;

	gl_FragColor = texture2D(webcam_texture, coord.st * sin(elapsed_time / 8));
}
